package com.study.controller;

import com.study.entities.Order;
import com.study.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@RequestMapping("order")
public class OrderController {

    @Autowired
    private IOrderService orderService;



    @GetMapping("{orderId}")
    public Order queryOrderById(@PathVariable("orderId") Long orderId) {
        // 根据id查询订单并返回
        return orderService.findOrder(orderId);
    }

    @GetMapping("/create")
    public String createOrder() {
        // 根据id查询订单并返回
        System.out.println(orderService.createOrder());
        return "Order created";
    }
}

